import api from '../../js/api';
import { formatDate } from "../../js/util"
const dayjs = require('dayjs')


Page({


    data: {

        rdate: null, //到货日期
        scode: null, //堆场
        scode_txt: null,

        sub_fld4: null,
        skuno: null,
        busiinvcode: null,
        sub_fld3: null,

        listDuichang: [],

        isShowRiqi: false,
        isShowScode: false,
        currentDate: new Date().getTime()

       
    },


    onLoad(options) {

    },


    onShow() {
        //获取堆场
        api.getDuichang().then((r) => {
            let res = r.data.map(({ scode, sname }) => ({ scode, name: sname }))
            this.setData({ listDuichang: res })
        })

    },


    showPop(e) {
        const key = e.currentTarget.id
        let data = {}
        data[key] = true
        this.setData(data)
    },
    onClose() {
        this.setData({
            isShowRiqi: false,
            isShowScode: false,
        })
    },
    selectDate(e) {
        let date = new Date(e.detail)
        this.setData({
            isShowRiqi: false,
            rdate: formatDate(date)
        })
    },
    selectScode(e) {
        this.setData({
            scode_txt: e.detail.name,
            scode: e.detail.scode,
            isShowScode: false
        })
    },

    chaxun() {

        let param = {}
        param.rdate = this.data.rdate
        param.scode = this.data.scode
        param.sub_fld4 = this.data.sub_fld4
        param.skuno = this.data.skuno
        param.busiinvcode = this.data.busiinvcode
        param.sub_fld3 = this.data.sub_fld3


        wx.navigateTo({
            url: '../KuCunChaXunNext/KuCunChaXunNext',
            success: (res) => {
                res.eventChannel.emit('param', param);
            }
        })
    }
})